const {Result} = require("../models/Result");
const {GetMenusByUserId} = require("../models/dao/menuDao");
const {array2Tree, getChildren, arrToTree} = require("../utils/data");




module.exports = {
    //根据用户ud获取用户信息
    getMenusByUserId: async ctx => {
        const id = ctx.params.id
        const r = new Result();
        if (!id) {
            ctx.body = r.fail("未知错误，查询失败")
        }
        let menus = await GetMenusByUserId(id);
        const menuTree = arrToTree(menus)
        ctx.body = r.succ(menuTree, '查询成功')
    },
}
